<!DOCTYPE HTML>
<html>
<head>
    <title>失联-找回</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .hideBorder{
        border: solid 0px;
    }
</style>
<body>
<div class="mini-fit" style="padding-left: 40px;padding-top: 20px;">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">

        <form id="form2" method="post" style="margin-left: 10px;">
            <div id="editform" class="form" >
                <table class="form-table"  >
                    <tr>
                        <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">姓&emsp;&emsp;名:</span></td>
                        <td style="width: 200px;line-height: 30px;">
                            <span style="width: 200px;color: #8B8B8B" >${pname!''}</span>
                        </td>
                    </tr>
                    <tr >
                        <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">性&emsp;&emsp;别:</span></td>
                        <td style="width: 200px;line-height: 30px;">
                            <span style="width: 200px;color: #8B8B8B" >${sex!''}</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">身份证号:</span></td>
                        <td style="width: 200px;line-height: 30px;">
                            <span style="width: 200px;color: #8B8B8B" >${idnum!''}</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">出生日期:</span></td>
                        <td style="width: 200px;line-height: 30px;">
                            <span style="width: 200px;color: #8B8B8B" >${age!''}</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">户籍地址:</span></td>
                        <td>
                            <span style="width: 200px;color: #8B8B8B" >${hjdz!''}</span>
                        </td>
                    </tr>
                    <#if "${localCode!''}" == "140000">
                        <tr>
                            <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">日常居住地:</span></td>
                            <td>
                                <span style="width: 200px;color: #8B8B8B">${juzhudi!''}</span>
                            </td>
                        </tr>
                    <#else>
                       <tr>
                           <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">居住地址:</span></td>
                           <td>
                               <span style="width: 200px;color: #8B8B8B">${juzhudi!''}</span>
                           </td>
                       </tr>
                    </#if>
                    <#if "${localCode!''}" != "140000">
                        <tr>
                            <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">失联原因:</span></td>
                            <td>
                                <span style="width: 200px;color: #8B8B8B" >${reason!''}</span>
                            </td>
                        </tr>
                    </#if>
                    <#if "${localCode!''}" == "140000">
                        <tr>
                            <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">人户分离时间:</span></td>
                            <td>
                                <span style="width: 200px;color: #8B8B8B">${dateTuoguan!''}</span>
                            </td>
                        </tr>
                    <#else>
                        <tr>
                            <td style="width: 80px;line-height: 30px;" align="right"><span style="color: #8B8B8B">失联时间:</span></td>
                            <td>
                                <span style="width: 200px;color: #8B8B8B">${dateTuoguan!''}</span>
                            </td>
                        </tr>
                    </#if>
                </table>
            </div>
        </form>
        <form id="form3" method="post" style="margin-left: 10px;">
            <div id="editform" class="form" >
                <table class="form-table"  >
                    <#--失联编号-->
                    <input id="id" name="id" value="${id!''}" class="mini-hidden"/>
                    <input id="isTuoguan" name="isTuoguan" value="2" class="mini-hidden"/>
                    <tr>
                        <td style="width: 80px;" align="right"><font color="#dc143c">*</font>找回时间:</td>
                        <td style="width: 200px">
                            <input id="dateZhaohui" name="dateZhaohui" allowInput="false" class="mini-datepicker" style="width: 200px;"  required="true" ondrawdate="onDrawDate" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 80px;" align="right"><font color="#dc143c">*</font>找回原因:</td>
                        <td >
                            <input id="zhaohuiReason"  name="zhaohuiReason" class="mini-textarea" style="width: 300px;height: 80px;"  required="true"/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
</div>
<div style="padding:2px;margin: 0 auto;text-align: center">
    <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">保存</a>
    <a class="mini-button" iconCls="fa-undo" plain="true" onclick="close('cancel')">取消</a>
</div>
<div>
    <br/>
</div>

<script type="text/javascript">
    mini.parse();
    var form2 = new mini.Form("form2");
    var form3 = new mini.Form("form3");

    function saveData(){
        var dateTuoguan = "${dateTuoguan!''}";

        form3.validate();
        if (form3.isValid() == false) {
            return;
        }
        var data = form3.getData();
        var dateZhaohui = new Date(data.dateZhaohui).format("yyyy-MM-dd");
        if(dateTuoguan>dateZhaohui){
            mini.alert("找回时间不能小于失联时间！");
            return ;
        }

        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/bjdxInfo/qbrygl/bjdxSldjSave",
            type: "post",
            data: {data: json},
            success: function (success) {
                mini.alert("保存成功","成功",window.CloseOwnerWindow);
            }
        });
    }

    function close(action){
        if(window.CloseOwnerWindow){
            window.CloseOwnerWindow(action);
        }else{
            window.close();
        }
    }

    /**
     * js格式化时间使用format声明
     * @param format
     * @returns {*}
     */
    Date.prototype.format =function(format) {
        var o = {
            "M+" : this.getMonth()+1, //month
            "d+" : this.getDate(), //day
            "h+" : this.getHours(), //hour
            "m+" : this.getMinutes(), //minute
            "s+" : this.getSeconds(), //second
            "q+" : Math.floor((this.getMonth()+3)/3), //quarter
            "S" : this.getMilliseconds() //millisecond
        }
        if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
            (this.getFullYear()+"").substr(4- RegExp.$1.length));
        for(var k in o)if(new RegExp("("+ k +")").test(format))
            format = format.replace(RegExp.$1,
                RegExp.$1.length==1? o[k] :
                    ("00"+ o[k]).substr((""+ o[k]).length));
        return format;
    }

    //找回时间不能选择比今天靠后的日期
    function onDrawDate(e) {
        //获取页面的失联时间
        var shilianDate = '${dateTuoguan!''}';
        var shilianDate1 = new Date(shilianDate);
        var date = e.date;
        //今天的日期
        var d = new Date();
        //选择的日期大于今天日期 不能选
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
        //找回时间不得早于失联时间
        if (date.getTime() < shilianDate1-86400000) {
            e.allowSelect = false;
        }
    }
</script>
</body>
</html>